
<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>Leo’s Markup Language &#8212; Leo 6.7.2 documentation</title>
    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="_static/classic.css" />
    <link rel="stylesheet" type="text/css" href="_static/custom.css" />
    
    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
    <script src="_static/jquery.js"></script>
    <script src="_static/underscore.js"></script>
    <script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
    <script src="_static/doctools.js"></script>
    <script src="_static/sphinx_highlight.js"></script>
    
    <script src="_static/sidebar.js"></script>
    
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Customizing Leo" href="customizing.html" />
    <link rel="prev" title="Leo’s Users Guide" href="usersguide.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="customizing.html" title="Customizing Leo"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="usersguide.html" title="Leo’s Users Guide"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="leo_toc.html">Leo 6.7.2 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="usersguide.html" accesskey="U">Leo’s Users Guide</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">Leo’s Markup Language</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="leo-s-markup-language">
<h1>Leo’s Markup Language<a class="headerlink" href="#leo-s-markup-language" title="Permalink to this heading">¶</a></h1>
<p id="index-0">Leo’s <strong>markup</strong> tells Leo how to create external files from &#64;file trees. Markup may appear in any body text, and <em>must</em> appear in the body of the &#64;file node itself.</p>
<p>There are two kinds of markup: <strong>section references</strong> (&lt;&lt; this is my section &gt;&gt;) and the <strong>&#64;others</strong> directive. Section references refer to <strong>named nodes</strong>, nodes whose <em>headlines</em> look like a section reference. &#64;others refers to all <em>other</em> (unnamed) nodes. Here is the body text of a typical &#64;file node for a python file:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@first</span> <span class="c1"># -*- coding: utf-8 -*-</span>
<span class="sd">&#39;&#39;&#39;whatever.py&#39;&#39;&#39;</span>
<span class="o">&lt;&lt;</span> <span class="n">imports</span> <span class="o">&gt;&gt;</span>
<span class="nd">@others</span>
<span class="c1"># That&#39;s all, folks</span>
<span class="nd">@language</span> <span class="n">python</span>
<span class="nd">@tabwidth</span> <span class="o">-</span><span class="mi">4</span>
</pre></div>
</div>
<p>A child node must define the &lt;&lt; import &gt;&gt; node. Other children will typically define classes, methods, functions and data.</p>
<p>When writing this file, Leo writes the first two lines:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@first</span> <span class="c1"># -*- coding: utf-8 -*-</span>
<span class="sd">&#39;&#39;&#39;whatever.py&#39;&#39;&#39;</span>
</pre></div>
</div>
<p>followed by the <em>body text</em> of the &lt;&lt; imports&gt;&gt; node, followed by the body text of all <em>other</em> nodes, in outline order, followed by the comment <em># That’s all, folks</em>.</p>
<p>Leo’s markup applies to scripts as well as external files. Leo’s execute-script command <strong>composes</strong> the script from the selected node, using Leo’s markup. For example: this body text defines the top-level part of a script:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="sd">&#39;&#39;&#39;My script&#39;&#39;&#39;</span>
<span class="o">&lt;&lt;</span> <span class="n">imports</span> <span class="o">&gt;&gt;</span>
<span class="k">class</span> <span class="nc">Controller</span><span class="p">:</span>
    <span class="c1"># Child nodes define the methods of this class.</span>
    <span class="nd">@others</span>
<span class="n">Controller</span><span class="p">(</span><span class="n">c</span><span class="p">)</span><span class="o">.</span><span class="n">run</span> <span class="c1"># c *is* defined.</span>
</pre></div>
</div>
<p><strong>Important</strong>: Leo recognizes section references <em>everywhere</em>, even inside strings or comments.
See <a class="reference external" href="FAQ.html#what-about-code-that-looks-like-a-section-reference">this FAQ entry</a>.</p>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="leo_toc.html">
              <img class="logo" src="_static/LeoLogo.svg" alt="Logo"/>
            </a></p>
  <div>
    <h4>Previous topic</h4>
    <p class="topless"><a href="usersguide.html"
                          title="previous chapter">Leo’s Users Guide</a></p>
  </div>
  <div>
    <h4>Next topic</h4>
    <p class="topless"><a href="customizing.html"
                          title="next chapter">Customizing Leo</a></p>
  </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>document.getElementById('searchbox').style.display = "block"</script>
        </div>
<div id="sidebarbutton" title="Collapse sidebar">
<span>«</span>
</div>

      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="customizing.html" title="Customizing Leo"
             >next</a> |</li>
        <li class="right" >
          <a href="usersguide.html" title="Leo’s Users Guide"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="leo_toc.html">Leo 6.7.2 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="usersguide.html" >Leo’s Users Guide</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">Leo’s Markup Language</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 1997-2023, Edward K. Ream.
      Last updated on February 28, 2023.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.3.0.
    </div>
  </body>
</html>